package com.platform.batch.base.dto;

import lombok.Getter;
import lombok.Setter;

/**
 * Title: ItemProcessResult
 * Description: 批处理流程数据处理统计
 * Date 2020/4/20
 *
 * @author wxw
 * @version v1.0
 */
public class BatchProcessResult {
    @Getter
    @Setter
    private Long totalCount = 0L;
    @Getter
    private Long errorCount = 0L;
    @Getter
    private Long inspectErrorCount = 0L;
    @Getter
    private Long questionCount = 0L;
    @Getter
    private Long repeatCount = 0L;
    @Getter
    @Setter
    private Long skippedCount = 0L;
    @Getter
    @Setter
    private Long filterCount = 0L;
    @Getter
    @Setter
    private Long readCount = 0L;
    @Getter
    @Setter
    private Long writeCount = 0L;

    @Getter
    @Setter
    private Long noRelateCount = 0L;

    @Getter
    @Setter
    private Long delayedRepeatCount = 0L;

    // ER宽表交换放入缓存数，数据保存到cacheCount字段
    @Getter
    @Setter
    private Long addCacheCount = 0L;

    @Getter
    @Setter
    private Long addCount = 0L;

    @Getter
    @Setter
    private Long updateCount = 0L;


    /**
     * 已经审核过的疑问数据，再次进行审核的数据量
     */
    @Getter
    @Setter
    private Long ignoreToAuditCount = 0L;

    public synchronized void increaseIgnoreCount() {
        ignoreToAuditCount++;
    }


    public synchronized void increaseErrorCount() {
        errorCount++;
    }

    public synchronized void increaseInspectErrorCount() {
        inspectErrorCount++;
    }

    public synchronized void increaseErrorCount(int count) {
        errorCount += count;
    }

    public synchronized void increaseQuestionCount() {
        questionCount++;
    }

    public synchronized void addSkippedCount(long count) {
        skippedCount += count;
    }

    public synchronized void addFilterCount(long count) {
        filterCount += count;
    }

    public synchronized void addTotalCount(long count) {
        totalCount += count;
    }

    public synchronized void increaseNoRelateCount() {
        noRelateCount++;
    }

    public synchronized void increaseDelayedRepeatCount() {
        delayedRepeatCount++;
    }

    public synchronized void increaseAddCount() {
        addCount++;
    }

    public synchronized void increaseAddCount(int count) {
        addCount = addCount + count;
    }

    public synchronized void increaseUpdateCount() {
        updateCount++;
    }

    public Long getCachedCount() {
        return totalCount == 0 ? totalCount : totalCount - questionCount - errorCount - filterCount - skippedCount
                - repeatCount - noRelateCount - inspectErrorCount;
    }

    public synchronized void addRepeatCount(long count) {
        repeatCount += count;
    }

    public synchronized void increaseAddCacheCount() {
        addCacheCount++;
    }

    public synchronized void reset() {
        this.errorCount = 0L;
        this.questionCount = 0L;
        this.repeatCount = 0L;
        this.noRelateCount = 0L;
        this.delayedRepeatCount = 0L;
        this.addCacheCount = 0L;
        this.skippedCount = 0L;
        this.filterCount = 0L;
        this.addCount = 0L;
        this.updateCount = 0L;
        this.inspectErrorCount = 0L;
    }
}
